var e = getApp(),
  t = e.requirejs("core"),
  a = e.requirejs("wxParse/wxParse");
Page({
  data: {
    hximg:''
  },
  onLoad: function (e) { 
   
    this.setData({
      id: e.id
    }), this.getDetail(),this.getsale()
    // ,this.gethexiao()
  }, 
  gethexiao:function(){
    var e = this;
    t.get("sale/coupon/my/writeOffCoupon", {
      couponid :e.data.id
    }, function(res){ 

    })
  },
  getsale:function(){
    var e = this;
    wx.setStorageSync('hexiaoid',e.data.id) 
    t.get("sale/coupon/my/generateWriteOffCode", {
      id:e.data.id
    }, function(res){ 
      console.log(res); 

                res =  res.split("iVBOR")[1] 
            var res2 =  ''
            var res3 = res2.concat(" ",res);  
            console.log(res3);
        e.setData({
          hximg:res3
        })
    })
  },
  getDetail: function () {
    var e = this;
    t.get("sale/coupon/my/getdetail", {
      id: this.data.id
    }, function (res) {
      res.error > 0 ? wx.navigateBack() : (a.wxParse("wxParseData", "html", res.detail.desc, e, "5"), e.setData({
        detail: res.detail,
        show: !0,
        // 核销路径
        // hximg:t.
      })) 




    })
  },
  receive: function (e) {
    var t, a = this.data.detail;
    0 != a.coupontype ? (1 == a.coupontype ? t = "/pages/member/recharge/index" : 2 == a.coupontype && (t = "/pages/sale/coupon/my/index"), wx.redirectTo({
      url: t
    })) : wx.redirectTo({
      url: "/pages/sale/coupon/my/list/index?couponid=" + this.data.id
    })
  }
});